package edu.xust.dao.impl;

import edu.xust.config.Repository;
import edu.xust.config.Resource;
import edu.xust.dao.PsManagerDao;
import edu.xust.entity.PsManager;
import edu.xust.entity.PsManagerExample;
import edu.xust.mapper.PsManagerMapper;
import edu.xust.page.PageInfo;

import java.util.List;

@Repository("psManagerDao")
public class PsManagerDaoImpl implements PsManagerDao {
    @Resource
    PsManagerMapper psManagerMapper;

    @Override
    public List<PsManager> getPsManagerByPage(PageInfo pageInfo) {
        PsManagerExample psManagerExample = new PsManagerExample();
        long l = psManagerMapper.countByExample(null);
        pageInfo.setItemCount((int) l);
        psManagerExample.setOffset(pageInfo.getOffset());
        psManagerExample.setLimit(pageInfo.getPageSize());
        return psManagerMapper.selectByExample(psManagerExample);
    }

    @Override
    public int addPsManager(PsManager psManager) {
        return psManagerMapper.insertSelective(psManager);
    }

    @Override
    public int updatePsManager(PsManager psManager) {
        return psManagerMapper.updateByPrimaryKey(psManager);
    }

    @Override
    public PsManager getPsManagerByPid(String pid) {
        return psManagerMapper.selectByPrimaryKey(pid);
    }


}
